package tk.jfree.example.es.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;

/**
 *  indexName：索引的名称（必填项）
 *     type：索引的类型
 *
 *     @Field(index=true,analyzer="ik_smart",store=true,searchAnalyzer="ik_smart",type = FieldType.Text)
 *        index：是否设置分词
 *        analyzer：存储使用的分词器
 *        searchAnalyze：搜索使用的分词器
 *        store：是否存储
 *        type: 类型
 *
 *        ik_smart 分词粒度较粗
 *        ik_max_word  分词粒度较细
 *
 * @author Cheng.Wei
 * @date 2019/04/28 22:58
 */
@Getter
@Setter
@ToString
@ApiModel
@Document(indexName  = "article")
public class Article implements Serializable {
    private static final long serialVersionUID = 4514182689952929834L;
    @Id
    @Field(store=true, index = false,type = FieldType.Long)
    @ApiModelProperty(value = "主键")
    private Long id;
    @Field(index=true, analyzer="ik_max_word", store=true, searchAnalyzer="ik_max_word", type = FieldType.Text)
    private String title;
    @Field(index=true, analyzer="ik_max_word", store=true, searchAnalyzer="ik_max_word", type = FieldType.Text)
    private String author;
    @Field(index=true, analyzer="ik_max_word", store=true, searchAnalyzer="ik_max_word", type = FieldType.Text)
    private String content;
}
